<template>
  <div class="book-box">
    <div
      class="book-item"
      v-for="(item, index) in list"
      @click="handleToDetail(item.id)"
      :key="index"
    >
      <van-image class="book-img" :src="item.image">
        <template v-slot:loading>
          <van-loading type="spinner" size="20" />
        </template>
      </van-image>
      <div class="book-info">
        <div class="book-name van-ellipsis">
          <!-- <span>{{index + 1}}</span> -->
          <span>{{item.name}}</span>
        </div>
        <div class="van-ellipsis">
          <span class="book-writer">{{item.writer}}</span>
          <span class="book-type">{{item.type}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Taro from "@tarojs/taro";
export default {
  name: "BookList",
  props: {
    list: {
      type: Array,
      default: [],
    },
  },
  methods: {
    handleToDetail(id) {
      Taro.navigateTo({
        url: `/pages/bookdetail/bookdetail?id=${id}`,
      });
    },
  },
};
</script>

<style scoped>
.book-box {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 46Px);
  overflow: scroll;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.book-box::-webkit-scrollbar {
  width: 0px;
}
.book-item {
  display: flex;
  padding: 40px 20px 20px 40px;
}
.book-img {
  height: 150px;
  width: 112.5px;
  margin-right: 40px;
  border-radius: 6px;
  box-shadow: 2px 2px 6px 2px #e2e2e2;
}
.book-name {
  font-size: 28px;
  font-weight: 600;
}
/* .book-name span:first-child {
  display: inline-flex;
  background: rgba(145, 199, 255, 1);
  width: 30px;
  height: 30px;
  text-align: center;
  color: white;
  border-radius: 20px;
  align-items: center;
  justify-content: center;
  font-size: 24px;
} */
.book-info {
  width: 72%;
  border-bottom: 1px solid rgba(232, 229, 229, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.book-writer {
  font-size: 26px;
}
.book-type {
  font-size: 26px;
}
</style>